<template>
	<view class="" >
		<u-navbar back-icon-color='#fff'   :border-bottom="false" is-back title=" " :background="{background:'#5A53CE'}"></u-navbar>
		<tags  :tableInfo='tableInfo' @ok='SureTags' @endTable='endTable' :user='user'></tags>

		<wr-state ref='mask' icon='checkmark-circle-fill' iconcolor='#52C41A' tags=' ' content="开台成功" @ready='ready'>
		</wr-state>
	</view>
</template>

<script>
	import charge from '../scan/components/charge.vue';
	import tags from '../scan/components/tags.vue'
	import wxpay from '@/common/wxpay.js'
	export default {
		components: {
			charge,
			tags
		},
		data() {
			return {
				tableInfo: '',
				user: '',
				cid: "",
				sid: ''
			}
		},
		onLoad(options) {
			if (options.sid) {
				this.sid = options.sid
			}
			if (options.cid) {
				this.cid = options.cid
			}
			this.getTable()
			this.getUser()
		},
		onShow() {
			
		},
		methods: {
			getUser() {
				this.$u.api.userInfo().then(res => {
					this.user = res;
				})
			},
			getTable() {
				this.$u.post('/index/carportDetail', {
					id: this.cid,
				}).then(res => {
					console.log(res,444)
					this.tableInfo = res;
					
				})
			},
			SureTags(e) {
				this.$u.post('/indent/orderStart', {
					carport_id: e,
				}).then(res => {
					if (Array.isArray(res)) {
						this.openDesk({
							id: e
						})
					} else {
						const wx = new wxpay(res);
						wx.pay().then(res => {
							this.openDesk({
								id: e
							})
						}).catch(err => {

						})
					}
					this.$refs.mask.show = true
				})
			},
			endTable(e) {
				uni.navigateTo({
					url: '/pages/scan/total?id=' + e
				})
				this.show = false
			},
			openDesk(item) {
				this.$u.post('/index/carportDetail', {
					id: item.id,
				}).then(res => {
					this.tableInfo = res;
				})
			}
		}
	}
</script>

<style>
</style>